#include <QtGui>
#include <QtCore/QTextCodec>
#include <QTranslator>
#include "gv_systemiopanelsDialog.h"
#include "gv_systemhomedialog.h"
#include "gv_home.h"
#include "gv_setting.h"

extern GV_Setting *gvsetting;
extern QDialog  *dialog;
GV_SystemIOPanelsDialog::GV_SystemIOPanelsDialog(QWidget *parent)
       : QDialog(parent)
{
    setupUi(this);

    QTranslator translator;
    translator.load(gvsetting->GV_GetLanguage(),".");
    qApp->installTranslator(&translator);
    reloadtext();

    connect(BackButton,SIGNAL(clicked()),this,SLOT(home()));
    //connect(CancelButton,SIGNAL(clicked()),this,SLOT(cancel()));
    connect(CancelButton,SIGNAL(clicked()),this,SLOT(home()));
    connect(AcceptButton,SIGNAL(clicked()),this,SLOT(accept()));

    connect(APanel1Button,SIGNAL(clicked()),this,SLOT(keyA()));
    connect(BPanel1Button,SIGNAL(clicked()),this,SLOT(keyB()));
    connect(CPanel1Button,SIGNAL(clicked()),this,SLOT(keyC()));
    connect(DPanel1Button,SIGNAL(clicked()),this,SLOT(keyD()));
    connect(EPanel1Button,SIGNAL(clicked()),this,SLOT(keyE()));
    connect(FPanel1Button,SIGNAL(clicked()),this,SLOT(keyF()));
    connect(GPanel1Button,SIGNAL(clicked()),this,SLOT(keyG()));
    connect(HPanel1Button,SIGNAL(clicked()),this,SLOT(keyH()));
    connect(IPanel1Button,SIGNAL(clicked()),this,SLOT(keyI()));
    connect(JPanel1Button,SIGNAL(clicked()),this,SLOT(keyJ()));
    connect(KPanel1Button,SIGNAL(clicked()),this,SLOT(keyK()));
    connect(LPanel1Button,SIGNAL(clicked()),this,SLOT(keyL()));
    connect(MPanel1Button,SIGNAL(clicked()),this,SLOT(keyM()));
    connect(NPanel1Button,SIGNAL(clicked()),this,SLOT(keyN()));
    connect(OPanel1Button,SIGNAL(clicked()),this,SLOT(keyO()));
    connect(PPanel1Button,SIGNAL(clicked()),this,SLOT(keyP()));
    connect(QPanel1Button,SIGNAL(clicked()),this,SLOT(keyQ()));
    connect(RPanel1Button,SIGNAL(clicked()),this,SLOT(keyR()));
    connect(SPanel1Button,SIGNAL(clicked()),this,SLOT(keyS()));
    connect(TPanel1Button,SIGNAL(clicked()),this,SLOT(keyT()));
    connect(UPanel1Button,SIGNAL(clicked()),this,SLOT(keyU()));
    connect(VPanel1Button,SIGNAL(clicked()),this,SLOT(keyV()));
    connect(WPanel1Button,SIGNAL(clicked()),this,SLOT(keyW()));
    connect(XPanel1Button,SIGNAL(clicked()),this,SLOT(keyX()));
    connect(YPanel1Button,SIGNAL(clicked()),this,SLOT(keyY()));
    connect(ZPanel1Button,SIGNAL(clicked()),this,SLOT(keyZ()));

    connect(CapPanel1Button,SIGNAL(clicked()),this,SLOT(keyCap()));
    connect(ShiftPanel1Button,SIGNAL(clicked()),this,SLOT(keyShift()));
    connect(num1Panel1Button,SIGNAL(clicked()),this,SLOT(keynum1()));
    connect(num2Panel1Button,SIGNAL(clicked()),this,SLOT(keynum2()));
    connect(num3Panel1Button,SIGNAL(clicked()),this,SLOT(keynum3()));
    connect(dotPanel1Button,SIGNAL(clicked()),this,SLOT(keydot()));
    connect(commaPanel1Button,SIGNAL(clicked()),this,SLOT(keycomma()));
    connect(_Panel1Button,SIGNAL(clicked()),this,SLOT(key_()));
    connect(SpacePanel1Button,SIGNAL(clicked()),this,SLOT(keySpace()));
    connect(BackspacePanel1Button,SIGNAL(clicked()),this,SLOT(keyBackspace()));

}
void GV_SystemIOPanelsDialog::reloadtext()
{
    //NameHintsLabel->setText(tr("Zones"));
}
void GV_SystemIOPanelsDialog::keyA()
{
    currentNum="A";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyB()
{
    currentNum="B";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyC()
{
    currentNum="C";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyD()
{
    currentNum="D";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyE()
{
    currentNum="E";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyF()
{
    currentNum="F";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyG()
{
    currentNum="G";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyH()
{
    currentNum="H";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyI()
{
    currentNum="I";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyJ()
{
    currentNum="J";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyK()
{
    currentNum="K";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyL()
{
    currentNum="L";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyM()
{
    currentNum="M";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyN()
{
    currentNum="N";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyO()
{
    currentNum="O";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyP()
{
    currentNum="P";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyQ()
{
    currentNum="Q";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyR()
{
    currentNum="R";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyS()
{
    currentNum="S";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyT()
{
    currentNum="T";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyU()
{
    currentNum="U";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyV()
{
    currentNum="V";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyW()
{
    currentNum="W";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyX()
{
    currentNum="X";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyY()
{
    currentNum="Y";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyZ()
{
    currentNum="Z";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyCap()
{
    //TODO
    showNumber();
}

void GV_SystemIOPanelsDialog::keyShift()
{
    //TODO
    showNumber();
}

void GV_SystemIOPanelsDialog::keynum1()
{
    currentNum="1";
    showNumber();
}

void GV_SystemIOPanelsDialog::keynum2()
{
    currentNum="2";
    showNumber();
}

void GV_SystemIOPanelsDialog::keynum3()
{
    currentNum="3";
    showNumber();
}

void GV_SystemIOPanelsDialog::keydot()
{
    currentNum=".";
    showNumber();
}

void GV_SystemIOPanelsDialog::keycomma()
{
    currentNum=",";
    showNumber();
}

void GV_SystemIOPanelsDialog::key_()
{
    currentNum="_";
    showNumber();
}

void GV_SystemIOPanelsDialog::keySpace()
{
    currentNum=" ";
    showNumber();
}

void GV_SystemIOPanelsDialog::keyBackspace()
{
    //TODO
    showNumber();
}

void GV_SystemIOPanelsDialog::showNumber()
{
    //TODO
    if(1){
        totalNum = totalNum + currentNum;
        lineEdit->setText(totalNum);
    }
}
void GV_SystemIOPanelsDialog::home()
{
    QDialog *dialog1 = new GV_SystemHomeDialog;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}

void GV_SystemIOPanelsDialog::accept()
{
    //TODO
}

void GV_SystemIOPanelsDialog::cancel()
{
    QDialog *dialog1 = new GV_SystemHomeDialog;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}



